package cn.com.cetccst.activation.ui;

import androidx.navigation.NavController;
import androidx.navigation.Navigation;

import cn.com.cetccst.uicomponents.binding.app.DataBindingConfig;
import cn.com.cetccst.uicomponents.binding.app.DataBindingFragment;

import cn.com.cetccst.activation.BR;
import cn.com.cetccst.activation.R;
import cn.com.cetccst.activation.databinding.FragmentRegisterBinding;
import cn.com.cetccst.activation.ui.viewmodel.RegisterViewModel;

public class RegisterFragment extends DataBindingFragment<FragmentRegisterBinding> {

    private RegisterViewModel viewModel;

    @Override
    protected void initViewModel() {
        viewModel = getFragmentScopeViewModel(RegisterViewModel.class);
    }

    @Override
    protected DataBindingConfig getDataBindingConfig() {
        init();
        return new DataBindingConfig(R.layout.fragment_register, BR.viewModel, viewModel).
                addBindingParam(BR.click, new Click());
    }

    private void init() {
        viewModel.requestFeatures(getContext());
    }

    public class Click {
        public void confirm() {
            NavController navController = Navigation.findNavController(getBinding().getRoot());
            navController.popBackStack();
        }
    }

}